package com.borqs.music.tasks;

import com.borqs.music.executor.Task;
import com.borqs.music.executor.TaskListener;
import com.borqs.music.http.HttpRequest;
import com.borqs.music.http.HttpResponse;
import com.borqs.music.http.RequestMethod;
import com.borqs.music.util.MusicConf;

import java.util.HashMap;

public class UpdateOnlineFavorTask extends Task {
    private String ticket;
    private String songId;
    private String isFavor;

    public UpdateOnlineFavorTask(TaskListener listener, String ticket, String songId, boolean isFavor) {
        super(listener);
        this.ticket = ticket;
        this.songId = songId;
        this.isFavor = isFavor ? "1" : "0";
    }

    @Override
    public Object handleResponse(HttpResponse resp) throws Exception {
        checkResponse(resp);
        return null;
    }

    @Override
    public HttpRequest prepareRequest() {
        HashMap<String, String> params = new HashMap<String, String>();
        params.put("songid", songId);
        params.put("isfavor", String.valueOf(isFavor));

        final String URL = MusicConf.getUrl(MusicConf.ReqType.MUSIC_UPDATE_ONLINE_FAVOR);
        HttpRequest request = new HttpRequest(RequestMethod.GET, URL, ticket, params);
        return request;
    }

}
